﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/FullSite.Master" Inherits="System.Web.Mvc.ViewPage<ToppingControl.Models.TopCordActModel.TopCordAct_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
   Get_CARD
   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%--KEY PAD--%>
   
   <div class="float-left" style="margin:0px!important">
      <h2 style="display:inline"> Topping Tail Computer</h2>
   </div>
   <div class="float-right" style="margin:0px!important; vertical-align:middle;">
      <div class="float-left" style="line-height:10px;">
         <h3>
            Topping NO.
            <%: Html.DisplayFor(model => model._Topno) %>
         </h3>
      </div>
      <div class="float-left" style="margin-left: 25px;line-height:15px;">
         <h3>
            Shift : <%: ViewBag.shift %></h3>
      </div>
      <div class="float-left" style="margin-left: 25px;line-height:15px;">
         <h3>
            Name :
            <% if (Request.IsAuthenticated)
               { %>
            <%:  User.Identity.Name %></h3>
      </div>
      <% } %>
   </div>
 
   <br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
    <style type="text/css">
    #newR
    {
     background-color:Yellow;  
       font-size:20px;
        width:120px; 
    }
        #newR:hover
    {     
     color:#999;
    }
    #fin
    {
        background-color:Red;
        font-size:20px;
        width:120px;
    }
      #footer
      {
        display:none;        
      }
      #body
      {
         height:100% !important;
      }
      .hide
      {
      display: none;
      }

      #data div
      {
         float: left;
         padding: 0px;
      }
      #data td, #prt td
      {
         font-size: 22px;
         height: 30px;
         text-align: left;
         padding-left: 10px;
      }
      input[type="text"]
      {
         height: 28px;
         width: 95%;
         font-size: 24px;
         background-color: #D3FFD3;
         border: 2px solid #999;
      }
      input[type="button"]:hover
      {
         cursor:pointer;
 
         border:2px solid #999;
         font-weight:bold; font-size: 22px;
      }
      input[type="button"]
      {
         cursor:pointer;
         margin:30px;
         font-weight:bold; font-size: 22px;
         width:185px;
         height:50px;
         color:#333333;
      }
      .gray
      {
         background-color: #ccc !important;
      }
       #txt50ds,#txt50os,#txt50wd ,#txt100ds,#txt100os,#txt100wd ,#txt200ds,#txt200os,#txt200wd ,#txt300ds,#txt300os,#txt300wd,#txt400ds,#txt400os,#txt400wd,#txt400ms
      {
         text-align:right;
      }
   </style>

</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="MainContent2" runat="server">
    <br />
   
<div id="numericInput" style="float:left; width:300px;" >   
   <table id="keypad" class="hide">
         <tr style="background-color:#696969;"><td colspan="3" style="text-decoration:none; text-align:right;">
         <img src="<%: Url.Content("~/Images/power.png")%> "  alt='' width="100px" height="75px" id="close" />
         </td></tr>
         <tr class="rowa" >
            <td class="key">
               1
            </td>
            <td class="key ">
               2
            </td>
            <td class="key ">
               3
            </td>
         </tr>
         <tr class="rowa" >
            <td class="key ">
               4
            </td>
            <td class="key ">
               5
            </td>
            <td class="key ">
               6
            </td>
         </tr>
         <tr class="rowa" >
            <td class="key ">
               7
            </td>
            <td class="key ">
               8
            </td>
            <td class="key ">
               9
            </td>
         </tr>
         <tr class="rowa" >
            <td class="btn">
               DEL
            </td>
            <td class="key ">
               0
            </td>
            <td class="key ">
               .
            </td>
         </tr>
      </table>
</div>
   <table width="95%" id="data">
      <tr>
         <td class="cell" style="width: 20%">
            Date
         </td>
         <td class="cell gray" style="width: 30%">
            <%: Model._Plandt  %>-<%: Model._Itemno  %>
         </td>
         <td class="cell">
            <div style="width: 40%">
               Production Date
            </div>
            <div style="width: 60%; border: 1px solid #ccc" class="gray">
               <%: Model._Prddate %>
            </div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Topped Cord
         </td>
         <td class="cell gray">
            <%: Model._Topcrdcd  %>
         </td>
         <td class="cell">
            <div style="width: 40%">
               Expired</div>
              <% if (WinNemoLib.StrUtil.IsEmpty(Model._Sample))
                 { %>
            <div style="width: 60%; border: 1px solid #ccc" class="gray">
               <%= Model._Expired%></div>
               <%}
                 else
                 { %>
               <div style="width: 60%">
               <input id="txtExp" type="text" class="request" value="<%=Model._Expired %>" /></div>
               <%} %>
          </td>
      </tr>
      <tr>
         <td class="cell">
            Manufacturer
         </td>
         <td class="cell gray">
            <%= Model._Manufc  %>
         </td>
         <td class="cell head">
            <div>
               0 -50 M.</div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Length
         </td>
         <td class="cell gray">
            <%: Model._HLength   %>
         </td>
         <td class="cell ">
            <div style="width: 33%">
               DS</div>
            <div style="width: 33%">
               OS</div>
            <div style="width: 33%">
               Width</div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Tire Cord
         </td>
         <td class="cell gray">
            <%: Model._Tcrdcd   %>
         </td>
         <td class="cell">
            <div style="width: 33%">
               <input id="txt50ds" type="text" class="request" value="<%= Model._50ds %>" /></div>
            <div style="width: 33%">
               <input id="txt50os" type="text" class="request" value="<%= Model._50os %>" /></div>
            <div style="width: 33%">
               <input id="txt50wd" type="text" class="request" value="<%= Model._50wd %>" /></div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Tire Cord Lot
         </td>
         <td class="cell gray">
            <%: Model._Tcrdlot %>
         </td>
         <td class="cell head">
            100 M.
         </td>
      </tr>
      <tr>
         <td class="cell">
            Tire Cord Expired
         </td>
         <td class="cell gray">
            <%: Model._HExp  %>
         </td>
         <td class="cell">
            <div style="width: 33%">
               DS</div>
            <div style="width: 33%">
               OS</div>
            <div style="width: 33%">
               Width</div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Compound
         </td>
         <td class="cell gray">
            <%: Model._Compound   %>
         </td>
         <td class="cell">
            <div style="width: 33%">
               <input id="txt100ds" type="text" value="<%= Model._100ds %>" class="txt" /></div>
            <div style="width: 33%">
               <input id="txt100os" type="text" value="<%= Model._100os %>" class="txt" /></div>
            <div style="width: 33%">
               <input id="txt100wd" type="text" value="<%= Model._100wd %>" class="txt" /></div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Compound Lot
         </td>
         <td class="cell gray">
            <%: Model._ComLot %>
         </td>
         <td class="cell head">
            200 M.
         </td>
      </tr>
      <tr>
         <td class="cell">
            Compound Pallet
         </td>
         <td class="cell gray">
            <%: Model._ComPlt  %>
         </td>
         <td class="cell">
            <div style="width: 33%">
               DS</div>
            <div style="width: 33%">
               OS</div>
            <div style="width: 33%">
               Width</div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            Compound Expire
         </td>
         <td class="cell gray">
            <%: Model._ComExp   %>
         </td>
         <td class="cell">
            <div style="width: 33%">
               <input id="txt200ds" type="text" value="<%= Model._200ds %>" class="txt" /></div>
            <div style="width: 33%">
               <input id="txt200os" type="text" value="<%= Model._200os %>" class="txt" /></div>
            <div style="width: 33%">
               <input id="txt200wd" type="text" value="<%= Model._200wd %>" class="txt" /></div>
         </td>
      </tr>
      <tr>
         <td class="cell" colspan="2">
         </td>
         <td class="cell head">
            300 M.
         </td>
      </tr>
      <tr>
         <td class="cell head" colspan="2">
            ROLL NO.
         </td>
         <td class="cell">
            <div style="width: 33%">
               DS</div>
            <div style="width: 33%">
               OS</div>
            <div style="width: 33%">
               Width</div>
         </td>
      </tr>
      <tr>
         <td class="cell" colspan="2" rowspan="6">
            <div id="rows" style="text-align: center; font-size: 8em;
               font-weight: bolder; width: 98%; line-height: 98%">
               <%= Model._Rollno %></div>
         </td>
         <td class="cell">
            <div style="width: 33%">
               <input id="txt300ds" type="text" value="<%= Model._300ds %>" class="txt" /></div>
            <div style="width: 33%">
               <input id="txt300os" type="text" value="<%= Model._300os %>" class="txt" /></div>
            <div style="width: 33%">
               <input id="txt300wd" type="text" value="<%= Model._300wd %>" class="txt" /></div>
         </td>
      </tr>
      <tr>
         <td class="cell head">
            400 M.
         </td>
      </tr>
      <tr>
         <td class="cell">
            <div style="width: 25%">
               DS</div>
            <div style="width: 25%">
               MS</div>
            <div style="width: 25%">
               OS</div>
            <div style="width: 25%">
               Width</div>
         </td>
      </tr>
      <tr>
         <td class="cell">
            <div style="width: 24%">
               <input id="txt400ds" type="text" value="<%= Model._400ds %>" class="txt" /></div>
            <div style="width: 24%">
               <input id="txt400ms" type="text" value="<%= Model._400ms %>" class="txt" /></div>
            <div style="width: 24%">
               <input id="txt400os" type="text" value="<%= Model._400os %>" class="txt" /></div>
            <div style="width: 24%">
               <input id="txt400wd" type="text" value="<%= Model._400wd %>" class="txt" /></div>
         </td>
      </tr>
      <tr>
      <td class="cell">
            <div style="width: 40%">
               Length(M.)
            </div>
            <div style="width: 60%">
               <input id="txtlen" type="text" class="request" value="<%=Model._Lenght %>" /></div>
         </td>
      </tr>
      <tr>

         <td>
            <div style="width: 40%">
               Compound STD Used (Kg.)</div>
            <div id="std" class="gray" 
                 style="width: 50%; border: 1px solid #999; text-align:center; line-height: 35px;">
            <%: Model._StdUsed %>
            </div>
         </td>
      </tr>
    
      
   </table>

   <table width="98%">
   <tr>
   <td style=" width:70%"><input id="back" type="button" class="btnFooter shadow" value="BACK" style="margin:10px" />
   <input id="save" type="button" class="btnFooter shadow"value="SAVE" style="margin:10px"  />
   <input id="prtBef" type="button" class="btnFooter shadow"value="PRINT BEFORE" style="margin:10px" />
   <input id="prtAt" type="button"class="btnFooter shadow" value="PRINT AFTER" style="margin:10px" /></td>
   <td > <div style="text-align:right; float:left;">
   <input id="newR" type="button" class="shadow"value="NEW ROLL"  /></div>
   
   <div style="text-align:right; float:right;"><input id="fin" type="button" class="btnFooter shadow"value="FINISH"  /></div></td>
   </tr>
   </table>
<div id="dialog-confirm" title="New Row?">
<p><span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0; display:none;"></span>
 Are you print before?</p>
</div>



</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="ScriptsSection" runat="server">
    <% if (false)
      { %>
   <script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
   <% }; %>
   <script type="text/javascript">

      var btClick;
      $(function () {
          window.history.forward(-1);
          if ('<%= Model._Sample %>' != "") {
              $("#txtExp").dateEntry({ dateFormat: 'dmy/' });
          }
          // ###########  SAVE + PRINT BEF ####################
          $("#numericInput").draggable();
          var clickNum = null;
          $('.key').click(function (event) {

              var numBox = clickNum;
              o = numBox.data('mask');

              var max = o.maxLength;

              if (numBox.val().length == max) {
                  return;
              }

              var v = $.trim(this.innerHTML);
              var valueArray = ($.trim(numBox.val())).split('')
              var idx = $.inArray(".", valueArray);

              if ((v == ".") && (idx > -1)) {
                  return;
              }

              if ($.trim(this.innerHTML) == ".") {
                  if ($.inArray(".", o.maskArray) < 0) {
                      return;
                  }
                  numBox.val(numBox.val() + '.');
                  return;
              }

              var i = valueArray.length;


              if (idx >= 0) {
                  var pt = o.maskArray.length - ($.inArray(".", o.maskArray));
                  var x = valueArray.length + 1 - idx;
                  if (x > pt) {
                      return;
                  }
                  i = $.inArray(".", o.maskArray) + 1;


              } else if ((i > 0) && (o.maskArray[i] == '.')) {
                  numBox.val(numBox.val() + '.');
              }

              if (o.maskNonFixedCharsArray[i] == 'undefine') {
                  return;
              }
              if (v <= o.maskNonFixedCharsArray[i]) {
                  numBox.val(numBox.val() + v);
              }
              if ((clickNum != null) && (clickNum.attr("id") == "txtlen")) {
                  var formu = parseFloat('<%: Model._Formula %>');
                  $("#std").html(cal_furmula($("#txtlen").val(), formu));
              }
              event.stopPropagation();
          });

          $('.btn,#close').click(function (event) {
              var numBox = clickNum
              if ($.trim(this.innerHTML) == 'DEL') {
                  if (numBox.val().length > 0) {
                      clickNum.val(numBox.val().substring(0, numBox.val().length - 1));
                  }
                  else {
                      numBox.val('');
                  }
              }
              else {
                  $("#keypad").slideToggle();
                  clickNum = null;
              }
              event.stopPropagation();
          });
          ////  KEY PAD ////

          $("#prtBef").click(function () {
              btClick = $(this);
              Save_data('true', '<%=Url.Action("Save_data") %>', '<%=Url.Action("PRINT_BEfore") %>');
          });

          $("#prtAt").click(function () {
              btClick = $(this);

              var blnR = validate_len();

              if (blnR == 'true') Save_data(blnR, '<%=Url.Action("Save_data") %>', '<%= Url.Action("After","PDF_PRINT") %>');

          });
          // ###########  NEW ROW ####################



          $("#dialog-confirm").dialog({
              autoOpen: false,
              resizable: false,
              height: 140,
              modal: true,
              buttons: {
                  "Yes": function () {
                      var bt = (btClick.attr("id"));
                      if (bt == 'newR') {
                          //$("#rows").text(parseInt($.trim($("#rows").text())) + 1);
                          Save_data('true', '<%=Url.Action("NewRow","TailLine") %>', '<%=Url.Action("Get_CARD")%>');
                          $(this).dialog("close");
                      }

                      if (bt == 'fin') {
                          Save_data('true', '<%=Url.Action("Finish","TailLine") %>', '<%=Url.Action("Index")%>');
                      }

                  },
                  Cancel: function () {
                      $(this).dialog("close");
                  }
              }
          });

          $("#newR").click(function () {
              btClick = $(this);
              var blnR = validate_len();
              if (blnR == 'true') $("#dialog-confirm").dialog("open");

          });

          if (typeof (Number.prototype.isBetween) === "undefined") {
              Number.prototype.isBetween = function (min, max, notBoundaries) {
                  var between = false;
                  if (notBoundaries) {
                      if ((this < max) && (this > min)) between = true;

                  } else {
                      if ((this <= max) && (this >= min)) between = true;

                  }

                  return between;
              }
          }
          function validate_len() {
              var blnR = 'true';

              $(".request").each(function () {
                  $(this).parent().find("font").empty();
                  if ($(this).val() == '') {
                      if (blnR == 'true') {
                          blnR = false;
                          $(this).focus();
                          alert('ระบุค่าไม่ครบ');
                      }
                      $(this).parent().append("<font color='red'>*</font>");
                      return;
                  }
              });

              $(".txt").parent().find("font").empty();

              var cnt = parseFloat($("#txtlen").val());

              if (cnt >= 400) {
                  cnt = 1;
              } else if (cnt.isBetween(300, 400)) {
                  cnt = 2;
              } else if (cnt.isBetween(200, 300)) {
                  cnt = 3;
              } else if (cnt.isBetween(100, 200)) {
                  cnt = 4;
              }

              //request

              switch (cnt) {
                  case 1:
                      if ($("#txt400ds").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt400ds").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt400ds").parent().append("<font color='red'>*</font>");

                      }
                      if ($("#txt400ms").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt400ms").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt400ms").parent().append("<font color='red'>*</font>");

                      }
                      if ($("#txt400os").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt400os").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt400os").parent().append("<font color='red'>*</font>");

                      }
                      if ($("#txt400wd").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt400wd").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt400wd").parent().append("<font color='red'>*</font>");

                      }

                  case 2:

                      if ($("#txt300ds").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt300ds").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt300ds").parent().append("<font color='red'>*</font>");

                      }

                      if ($("#txt300os").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt300os").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt300os").parent().append("<font color='red'>*</font>");

                      }
                      if ($("#txt300wd").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt300wd").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt300wd").parent().append("<font color='red'>*</font>");

                      }


                  case 3:

                      if ($("#txt200ds").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt200ds").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt200ds").parent().append("<font color='red'>*</font>");

                      }

                      if ($("#txt200os").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt200os").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt200os").parent().append("<font color='red'>*</font>");

                      }
                      if ($("#txt200wd").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt200wd").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt200wd").parent().append("<font color='red'>*</font>");

                      }


                  case 4:
                      if ($("#txt100ds").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt100ds").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt100ds").parent().append("<font color='red'>*</font>");

                      }

                      if ($("#txt100os").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt100os").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt100os").parent().append("<font color='red'>*</font>");

                      }
                      if ($("#txt100wd").val() == "") {
                          if (blnR == 'true') {
                              blnR = false;
                              $("#txt100wd").focus();
                              alert('ระบุค่าไม่ครบ');
                          }
                          $("#txt100wd").parent().append("<font color='red'>*</font>");

                      }

              } return blnR;
          }

          // ###########  FINI ####################
          $("#fin").click(function () {
              btClick = $(this);
              var blnR = validate_len();
              if (blnR == 'true') $("#dialog-confirm").dialog("open");
              //           
          });


          $("#back").click(function () {
              var url = '<%= Url.Action("Index") %>';
              window.location = url;
          });

          $("#txtlen").focus();

          // cal_formula
          function cal_furmula(len, formula) {
              var formu = parseFloat(formula);
              if (formu <= 0) return 0;
              var result = (parseFloat(len) / 100) * formu;
              if ((result % parseInt(result)) != 0) {
                  result = result.toFixed(3);
              }
              return result;
          }

          $("#txtlen,#txtWidgth").click(function (event) {
              var parentOffset = $(this).offset();
              var o = {
                  left: 333,
                  top: 325
              };
             
              if ((clickNum != null) && (clickNum.attr("id") == "txtlen")) {
                  var formu = parseFloat('<%: Model._Formula %>');
                  $("#std").html(cal_furmula($("#txtlen").val(), formu));
              }
              if ((clickNum == null) || ($(this).attr("id") == clickNum.attr("id"))) $("#keypad").slideToggle().offset(o);
              clickNum = $(this);
              event.stopPropagation();
          });


          $('#txt50ds,#txt50os,#txt50wd ,#txt100ds,#txt100os,#txt100wd ,#txt200ds,#txt200os,#txt200wd ,#txt300ds,#txt300os,#txt300wd,#txt400ds,#txt400os,#txt400wd,#txt400ms')
               .click(function (event) {
                   var o = {
                       left: 333,
                       top: 325
                   };


                   if ((clickNum != null) && (clickNum.attr("id") == "txtlen")) {
                       var formu = parseFloat('<%: Model._Formula %>');
                       $("#std").html(cal_furmula($("#txtlen").val(), formu));
                   }

                   if ((clickNum == null) || ($(this).attr("id") == clickNum.attr("id"))) $("#keypad").slideToggle().offset(o);
                   clickNum = $(this);
                   event.stopPropagation();

               });



          $("#txtlen").change(function () {
              var formu = parseFloat('<%: Model._Formula %>');
              $("#std").html(cal_furmula($("#txtlen").val(), formu));
          });

          $('#txt50ds,#txt50os,#txt100ds,#txt100os,#txt200ds,#txt200os,#txt300ds,#txt300os,#txt400ds,#txt400os,#txt400ms')
               .setMask("9.99").attr("maxlength", 4);
          $('#txt50wd ,#txt100wd ,#txt200wd ,#txt300wd,#txt400wd,#txtlen,#txtWidgth')
               .setMask("999.99").attr("maxlength", 6);

          // ###########  SAVE ####################

          $("#save").click(function () {
              btClick = $(this);
              Save_data('true', '<%=Url.Action("Save_data","TailLine") %>');
          });

      });
       /// function

   /********* Save ********/
      function Save_data(blnR, getUsersUrl, action) {

               if (blnR == 'true') {
                   var exp = '<%: Model._Expired %>';
                   if ('<%= Model._Sample %>' != "") {
                       exp = $("#txtExp").val();
                   }
                  callScriptMethod(getUsersUrl, { thedata: {
                     _Manufc: '<%: Model._Manufc %>',
                     _Topno: '<%:Model._Topno %>',
                     _Shift:'<%:  ViewBag.shift %>',
                     _Itemno: '<%:Model._Itemno %>',
                     _Plandt: '<%:Model._Plandt %>',
                     _Topcrdcd: '<%: Model._Topcrdcd  %>',
                     _Tcrdcd: '<%: Model._Tcrdcd  %>',
                     _Tcrdlot: '<%: Model._Tcrdlot%>',
                     _HLength: '<%:Model._HLength %>',
                     _HExp: '<%: Model._HExp %>',
                     _Compound: '<%: Model._Compound %>',
                     _ComLot: '<%: Model._ComLot %>',
                     _ComPlt: '<%: Model._ComPlt %>',
                     _Prddate: '<%: Model._Prddate %>',
                     _Rollno: $("#rows").text(),
                     _Lenght: $("#txtlen").val(),
                     _Widgth: $("#txtWidgth").val(),
                     _Expired: exp,
                     _50ds: $("#txt50ds").val(),
                     _50os: $("#txt50os").val(),
                     _50wd: $("#txt50wd").val(),
                     _100ds: $("#txt100ds").val(),
                     _100os: $("#txt100os").val(),
                     _100wd: $("#txt100wd").val(),
                     _200ds: $("#txt200ds").val(),
                     _200os: $("#txt200os").val(),
                     _200wd: $("#txt200wd").val(),
                     _300ds: $("#txt300ds").val(),
                     _300os: $("#txt300os").val(),
                     _300wd: $("#txt300wd").val(),
                     _400ds: $("#txt400ds").val(),
                     _400ms: $("#txt400ms").val(),
                     _400os: $("#txt400os").val(),
                     _400wd: $("#txt400wd").val(),
                     _StdUsed: $.trim($("#std").html()),
                     _Empname: '<%: User.Identity.Name %>',
                     _ComExp: '<%: Model._ComExp %>'
                  }
                  },action)
               } //if
            }
   
   /********* AJAX ********/

   function callScriptMethod(url, jsonObject, action, callback, async) {

      callback = callback || function () { };
      async = (async == null || async);

      $.ajax({
         type: "POST",
         contentType: "application/json; charset=utf-8",
         url: url,
         data: JSON.stringify(jsonObject),
         dataType: "json",
         async: async,
         success: function (data) {

            if (data.success != "0") {
             
               if (btClick.attr("id") == "save") alert(data.message);
               $("#dialog-confirm").dialog("close");

               if (action != null) {
                  if (action == '<%=Url.Action("PRINT_BEfore") %>') {
                     //string topcode , string cust , string tirelot,string rFrm
                     action = action + '?topcode=' + '<%: Model._Topcrdcd  %>' + '&cust=' + '<%: Model._Manufc %>'
                              + '&tirelot=' + '<%: Model._Tcrdlot%>' + '&rollno=' + $("#rows").text() + '&prddt=' + '<%: Model._Prddate %>';
                  }
                  if (action == '<%= Url.Action("After","PDF_PRINT")%>') {
                     //string topcode , string cust , string tirelot,string rFrm

                     var para = '?topcode=' + '<%: Model._Topcrdcd  %>' + '&cust=' + '<%: Model._Manufc %>'
                              + '&tirelot=' + '<%: Model._Tcrdlot%>'
                              + '&rollno=' + '<%= Model._Rollno %>'
                              + '&prddt=' + '<%: Model._Prddate %>';
                     window.open(action + para, "printafter", "fullscreen=no");
                     action=null;
                  }
                  if (action != null) window.location = action;
               }
            }else  alert(data.message);
         },
         error: function (xhr, status, error) {
            var err = xhr.responseText;
            alert(err.Message);
         }
      });
   }

   </script>
</asp:Content>
